package com.ciei.dpagm.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by wzx on 11/8/2017.
 */
public class DateToString implements ConvertInterface<Date, String> {

    private String pattern;

    public DateToString(){
        this.pattern = "yyyy-MM-dd HH:mm:ss";
    }

    public DateToString(String pattern){
        this.pattern  = pattern;
    }

    @Override
    public String write(Date date) {
        return new SimpleDateFormat(pattern).format(date);
    }
}
